﻿$(function () {
    var Id = getParam("id");
    loadTables(Id);
});

function loadTables(Id) {
    $("#Toppic").html("");
    $("#Name").html("");
    $("#ContactNumber").html("");
    $("#Address").html("");
    $("#SQMJ").html("");
    $("#Remarks").html("");   
    $.ajax({
        type: "GET",
        url: "/Department/GetById?id=" + Id + "&_t=" + new Date().getTime(),
        success: function (data) {

            $("#Toppic").html("<img src='/UploadFiles/" + data.picPath + "' style='width: 100%;'>");

            $("#Name").html("<span class='weui-form-preview__value'>" + data.name + "</span>");

            $("#ContactNumber").html("<span class='weui-form-preview__value'>" + data.contactNumber + "</span>");

            $("#Address").html("<span class='weui-form-preview__value'>" + data.address + "</span>");

            $("#SQMJ").html("<a class='weui-form-preview__value' href='/Department/Police'>点击查看社区民警</a>");
            $("#Remarks").html("<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + data.remarks + "</p>");
            
        }
    })
};

//获取URL上的参数
function getParam(paramName) {
    paramValue = "";
    isFound = false;
    if (this.location.search.indexOf("?") == 0 && this.location.search.indexOf("=") > 1) {
        arrSource = unescape(this.location.search).substring(1, this.location.search.length).split("&");
        i = 0;
        while (i < arrSource.length && !isFound) {
            if (arrSource[i].indexOf("=") > 0) {
                if (arrSource[i].split("=")[0].toLowerCase() == paramName.toLowerCase()) {
                    paramValue = arrSource[i].split("=")[1];
                    isFound = true;
                }
            }
            i++;
        }
    }
    return paramValue;
}